-- GameFuncSettingM
-- create By zouyb
-- 游戏功能设置

module("GameFuncSettingM", package.seeall);

-- 功能设置配置
local gameFuncConfig = {};

-- 功能开关
local gameFuncSet = {};

-- 载入配置表
local _init = false;
local loadCsv = function()
    if _init then return; end
    _init = true;

    -- 载入配置表
    local csv = get_game_func_setting_CSV();
    for i = 1, #csv do
        gameFuncConfig[csv[i]["id"]] = csv[i];
    end
end

-- 初始化模块
function init()
    -- 清除
    gameFuncSet = {};

    loadCsv();
end

-- 获取子规则
function query(id, path)
    local m = gameFuncConfig[id]
    if not m or path == "" or not path then
        return m
    end

    return m[path]
end

-- 更新功能设置
function updateGameFuncSetting(funcSetting)
    gameFuncSet = funcSetting;
end

-- 获取推送设置
function getFuncSetting()
    return gameFuncSet;
end

-- 是否和原本设置相同
function isSettingChanged(inputSetting)
    for key, value in pairs(inputSetting) do
        if (gameFuncSet[key] ~= value) then
            return true;
        end
    end
    return false;
end
